package main

import (
	"fmt"
	"time"

	"github.com/gorhill/cronexpr"
)

func main() {
	// 支持 秒，年（2018-2099）
	// 每5秒执行一次
	expr, err := cronexpr.Parse("*/5 * * * * * *")
	if err != nil {
		fmt.Print(err)
	}

	now := time.Now()

	nextTime := expr.Next(now)
	fmt.Print(nextTime)

	time.AfterFunc(nextTime.Sub(now), func() {
		fmt.Print("被调度了：", nextTime)
	})

	select{}
}
